import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'yk_pda_plugin_platform_interface.dart';

/// An implementation of [YkPdaPluginPlatform] that uses method channels.
class MethodChannelYkPdaPlugin extends YkPdaPluginPlatform {
  /// The method channel used to interact with the native platform.
  @visibleForTesting
  final methodChannel = const MethodChannel('yk_pda_plugin');
  
  final eventChannel = const EventChannel('yk_pda_plugin/events');

  Stream<dynamic>? _stream;

  MethodChannelYkPdaPlugin() {
    _stream = eventChannel.receiveBroadcastStream();
  }

  @override
  Future init(StreamController streamController) {
    _stream?.listen((value) {
      streamController.add(value);
    });
    return Future.value();
  }
}
